package com.hongyuan.sellfitness.ui.person.activity;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;
import com.hongyuan.sellfitness.R;
import com.hongyuan.sellfitness.base.AppViewModelFactory;
import com.hongyuan.sellfitness.base.CustomActivity;
import com.hongyuan.sellfitness.databinding.ActivitySettingBinding;
import com.hongyuan.sellfitness.ui.person.view_mode.SettingViewModel;
import com.hongyuan.sellfitness.utils.CustomDialog;

import me.tatarka.bindingcollectionadapter2.BR;

public class SettingActivity extends CustomActivity<ActivitySettingBinding, SettingViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_setting;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public SettingViewModel initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(SettingViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();
        binding.comBack.setOnClickListener(view -> finish());
    }


    @Override
    public void initViewObservable() {
        super.initViewObservable();

        viewModel.uc.outLogin.observe(this, aVoid -> {
            CustomDialog.promptDialog(this, "确定要退出登录吗？", "确定！", "不确定？", false, v1 -> {
                if(v1.getId() == R.id.isOk){
                    //退出登录
                    viewModel.outLogin();
                }
            });
        });
    }
}
